<%--
    Document   : enviaremailCandidatos
    Created on : 11-ene-2012, 10:12:02
    Author     : Jon Mikel/Jon
--%>

<%@page import="com.ipartek.formacion.gestformwww.controlador.Verificador"%>
<%@page import="com.ipartek.formacion.gestformwww.modelo.beans.Candidato"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@include file="validarusuario.jsp" %>
<div class="contenido">
    <h2 align="center">Enviar Email</h2>
    <form action="enviar-correo-candidato-accion.do" name="emailCandidato" method="POST">
        <input type="hidden" name="aleatorioEnviarEmail" value="<%=Math.random()%>" />
        <input type="hidden" name="idCon" value="<%=request.getParameter("idCon")%>"/>
        <div id="submenu">
            <%@include file="menuenviarmailcandidato.jsp"%>
        </div><br>
        <%ArrayList<ArrayList<String>>plantilla=(ArrayList<ArrayList<String>>)request.getAttribute("plantillas");%>
        <% ArrayList<Candidato> candidatos = (ArrayList<Candidato>) request.getAttribute("listacandidatos");%>
        <jsp:include page="excepciones.jsp" flush="true" />
        <jsp:include page="errores.jsp" flush="true" />
            <table width="100%">
                <thead>
                <tr>
                    <th width="50%">Nombre</th>
                    <th width="50%">Email</th>
                </tr>
                </thead>
            </table>

            <%for (Candidato Candidato : candidatos) {%>
            <table width="100%">
                <tr>
                    <td width="50%">
                        <label for="<%=Candidato.getCanId()%>" ><%=Candidato.getCanNom()%>&nbsp;<%=Candidato.getCanApe1()%>&nbsp;<%=Candidato.getCanApe2()%></label>
                        <input type="hidden" name="canId" value="<%=Candidato.getCanId()%>" />
                    </td>
                    <td width="50%">
                        <%if ((Candidato.getCanMail() != null && Verificador.esEmail(Candidato.getCanMail()))){%>
                        <input type="text" name="email" value="<%=Candidato.getCanMail() %>" size="30"/>
                        <input type="hidden" name="nuevo" value="false" />
                        <%} else {%>
                        <input type="text" name="email" size="30"/>
                        <input type="hidden" name="nuevo" value="true" />
                        <%}%>
                    </td>
                </tr>
                <%}%>

                <tr>
    </table>
                <br><br>
                 <table>
                     Plantilla:&nbsp; <select name="tituloplantilla" onchange="javascript:document.emailCandidato.asuntoplantilla.selectedIndex=this.selectedIndex;document.emailCandidato.cuerpoplantilla.selectedIndex=this.selectedIndex;document.emailCandidato.asunto.value=document.emailCandidato.asuntoplantilla.value;document.emailCandidato.textoemail.value=document.emailCandidato.cuerpoplantilla.value">
                      <option>--Texto Libre--</option>
                <%for (ArrayList<String> Plantilla:plantilla){%>
                <option value="<%=Plantilla.get(0)%>"><%=Plantilla.get(0)%></option>
                        <%}%>
                  </select>
                   <select name="asuntoplantilla" style="display: none">
                       <option></option>
                <%for (ArrayList<String> Plantilla:plantilla){%>
                <option value="<%=Plantilla.get(1)%>"><%=Plantilla.get(1)%></option>
                        <%}%>
                  </select>
                   <select name="cuerpoplantilla" style="display: none">
                       <option></option>
                <%for (ArrayList<String> Plantilla:plantilla){%>
                <option value="<%=Plantilla.get(2)%>"><%=Plantilla.get(2)%></option>
                        <%}%>
                  </select>
                </table><br>
                <table>
                    <tr>
                    <td width="100%">Asunto:&nbsp; <input type="text" name="asunto" value="" size="68%"/>
                </tr>
                <tr>
                    <td  width="100%">Texto:&nbsp;</td>
                </tr>
    </table>
    <table width="100%">
                <tr>
                    <td><textarea name="textoemail" cols="200" rows="15" style="width:85%" onkeyup="if (!validarCaracteres(this.value, true)) this.value=cadenaCorrecta(this.value);"><%if (request.getParameter("textoemail") != null) {%><%= request.getParameter("textoemail")%><%}%></textarea></td>
                </tr>
    </table>
            <br>
    </form>
</div>
